Repository navigation
#patch: Compile the Spock extension statically so it loads on Groovy 6 - #207
Open
ErkoRisthein wants to merge 1 commit into
Open
ErkoRisthein wants to merge 1 commit into
ErkoRisthein wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the Spock extension’s Groovy 6 compatibility changes.
No open issues 🎉
What changed in this PR
Updates the Spock snapshot extension to load on Groovy 6 by removing dynamically compiled references to the deleted CallSiteArray class, while retaining the existing Groovy 2.5.8 and Spock 1.3 compilation baseline.
Changes:
- Statically compiles both extension classes and adds explicit types where needed.
- Replaces dynamic iteration and spread operations with plain loops.
- Adds a bytecode regression test that checks for
CallSiteArrayreferences.
| File | Description |
|---|---|
| java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/spock/GroovyRuntimeCompatibilitySpec.groovy | Checks compiled extension classes for references to the removed call-site cache. |
| java-snapshot-testing-spock/src/main/groovy/au/com/origin/snapshots/spock/SnapshotMethodInterceptor.groovy | Adds static compilation, explicit types, and indexed parameter iteration. |
| java-snapshot-testing-spock/src/main/groovy/au/com/origin/snapshots/spock/SnapshotExtension.groovy | Adds static compilation and registers feature interceptors through a plain loop. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@EnableSnapshotscan't start on Groovy 6, so every Spock spec that uses it fails at initialization:The module is compiled with dynamic Groovy 2.5.8, so its classes carry call site caches built on
CallSiteArray, and Groovy 6 no longer has that class.Change
@CompileStaticonSnapshotExtensionandSnapshotMethodInterceptor, so the compiled classes no longer referenceCallSiteArray. The module still compiles against Groovy 2.5.8 and Spock 1.3.forloops replaceeachWithIndexand the spread operator, so the static code doesn't bind toDefaultGroovyMethodssignatures at compile time.logis typed asLogger, which static compilation needs.GroovyRuntimeCompatibilitySpecfails if an extension class referencesCallSiteArray. The module's tests run on Groovy 2.5, so this checks the bytecode rather than running on Groovy 6.Verification
./gradlew :java-snapshot-testing-spock:buildpasses.I also published the branch with
publishToMavenLocaland ran a downstream project's snapshot tests against it: 7 test classes (Spock and JUnit 5), 34 tests, compiled with the Groovy version in the table.Static compilation binds method calls at compile time, so the risk to check is a Spock API that differs between 1.3 and later versions. Spock 1.3 is covered by the module's tests and 2.5 by the runs above. I did not run other Spock 2.x versions.